package com.xy.ahoy.ui.launcher

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavHostController
import com.xy.compose.resource_libs.R
import com.xy.compose.nav.routes.MainRouter
import com.xy.compose.resource_libs.FontColor
import com.xy.compose.resource_libs.ThemeColor
import kotlinx.coroutines.delay

@Composable
fun LauncherBody(nav: NavHostController){
    Box(modifier = Modifier.fillMaxSize().background(ThemeColor)){
        Row (modifier = Modifier.align(alignment = Alignment.Center), verticalAlignment = Alignment.CenterVertically){
            Image(
                modifier = Modifier.size(47.dp, 52.dp),
                painter = painterResource(R.mipmap.icon_launcher_logo),
                contentDescription = ""
            )
            Text(text = "Ahoy", color = FontColor, fontSize = 50.sp)
        }
        Image(
            modifier = Modifier.padding(bottom = 20.dp).size(172.dp, 70.dp).align(alignment = Alignment.BottomCenter),
            painter = painterResource(R.mipmap.icon_launcher_bottom),
            contentDescription = ""
        )
    }

    LaunchedEffect(Unit) {
        // 延迟3000毫秒（3秒）
        delay(3000)
        nav.navigate(MainRouter.LOGIN_PAGE){
            popUpTo(MainRouter.LAUNCHER_PAGE){
                inclusive = true //设为true表示包含启动页面本身也会被从返回栈中移除
            }
        }
    }
}